package com.hzdl.car.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.hzdl.car.bean.Menu;
import com.hzdl.car.mapper.MenuMapper;
import com.hzdl.car.service.MenuService;
import com.hzdl.car.vo.MenuVo;
import com.hzdl.car.vo.TreeNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceimpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;
    @Override
    public List<TreeNode> findByPid(Integer pid) {
        return menuMapper.findByPid(pid);
    }

    @Override
    public PageInfo<Menu> findWhere(MenuVo menuVo) {
        PageHelper.startPage(menuVo.getPage(),menuVo.getLimit());
        List<Menu> list = menuMapper.findWhere(menuVo);

        return new PageInfo<>(list);
    }

    @Override
    public int add(MenuVo menuVo) {
        return menuMapper.add(menuVo);
    }

    @Override
    public int update(MenuVo menuVo) {
        return menuMapper.update(menuVo);
    }

    @Override
    public int delete(Integer id) {
        return menuMapper.delete(id);
    }

    @Override
    public int countByPid(Integer id) {
        return menuMapper.countByPid(id);
    }

    @Override
    public List<TreeNode> findByUid(Integer uid) {
        return menuMapper.findByUid(uid);
    }
}
